<template>
  <a-card :bordered='false'>
    <!-- 查询区域 -->
    <div class='table-page-search-wrapper'>
      <a-form layout='inline' @keyup.enter.native='searchQuery'>
        <a-row :gutter='24'>
          <a-col :xl='6' :lg='7' :md='8' :sm='24'>
            <a-form-item label='城市服务商' style='margin-right: 10px' >
              <serveSelect @selectClick='selectClick' :value='queryParam.agencyCode'></serveSelect>
            </a-form-item>
          </a-col>
<!--          <a-col :xl='6' :lg='7' :md='8' :sm='12'>-->

<!--          </a-col>-->
          <span style='float: left; overflow: hidden' class='table-page-search-submitButtons'>
              <a-button type='primary' @click='searchReset' icon='reload' style='margin-left: 8px'>重置</a-button>
            </span>
        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class='table-operator'>
      <a-button @click='handleAdd' type='primary' icon='plus'>新增</a-button>
<!--      <a-button type='primary' icon='download' @click="handleExportXls('车费配置表')">导出</a-button>-->
<!--      <a-upload-->
<!--        name='file'-->
<!--        :showUploadList='false'-->
<!--        :multiple='false'-->
<!--        :headers='tokenHeader'-->
<!--        :action='importExcelUrl'-->
<!--        @change='handleImportExcel'-->
<!--      >-->
<!--        <a-button type='primary' icon='import'>导入</a-button>-->
<!--      </a-upload>-->
      <a-dropdown v-if='selectedRowKeys.length > 0'>
        <a-menu slot='overlay'>
          <a-menu-item key='1' @click='batchDel'>
            <a-icon type='delete' />
            删除
          </a-menu-item>
        </a-menu>
        <a-button style='margin-left: 8px'> 批量操作
          <a-icon type='down' />
        </a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class='ant-alert ant-alert-info' style='margin-bottom: 16px'>
        <i class='anticon anticon-info-circle ant-alert-icon'></i> 已选择
        <a style='font-weight: 600'>{{ selectedRowKeys.length }}</a
        >项
        <a style='margin-left: 24px' @click='onClearSelected'>清空</a>
      </div>

      <a-table
        ref='table'
        size='middle'
        bordered
        rowKey='id'
        :columns='columns'
        :dataSource='dataSource'
        :pagination='ipagination'
        :loading='loading'
        class='j-table-force-nowrap'
        :rowSelection='{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }'
        @change='handleTableChange'
      >
        <span slot='action' slot-scope='text, record'>
          <a @click='handleEdit(record)'>编辑</a>

          <a-divider type='vertical' />
          <a-dropdown>
            <a class='ant-dropdown-link'>更多 <a-icon type='down' /></a>
            <a-menu slot='overlay'>
              <a-menu-item>
                <a-popconfirm title='确定删除吗?' @confirm='() => handleDelete(record.id)'>
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <xhdjCarPrice-modal ref='modalForm' @ok='modalFormOk'></xhdjCarPrice-modal>
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import XhdjCarPriceModal from './modules/XhdjCarPriceModal'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import serveSelect from '@/components/serveSelect.vue'

export default {
  name: 'XhdjCarPriceList',
  mixins: [JeecgListMixin],
  components: {
    XhdjCarPriceModal, serveSelect
  },
  data() {
    return {
      description: '车费配置表管理页面',
      // 表头
      columns: [
        {
          title: '多少公里内免费(通用)',
          align: 'center',
          dataIndex: 'distanceFree',
          customRender: (text, record) => {
            return record.distanceFree+"km"
          }
        },
        {
          title: '起步价距离(通用)',
          align: 'center',
          dataIndex: 'startDistance',
          customRender: (text, record) => {
            return record.startDistance+"km"
          }
        },
        {
          title: '白天起步价',
          align: 'center',
          dataIndex: 'startPrice',
          customRender: (text, record) => {
            return record.startPrice+"元"
          }
        },
        {
          title: '白天每公里费用',
          align: 'center',
          dataIndex: 'distancePrice',
          customRender: (text, record) => {
            return record.distancePrice+"元"
          }
        },
        {
          title: '白天开始时间',
          align: 'center',
          dataIndex: 'startTime'
        },
        {
          title: '白天结束时间',
          align: 'center',
          dataIndex: 'endTime'
        },
        // 晚上
        {
          title: '夜间起步价',
          align: 'center',
          dataIndex: 'eveningStartPrice',
          customRender: (text, record) => {
            return record.eveningStartPrice+"元"
          }
        },
        {
          title: '夜间每公里费用',
          align: 'center',
          dataIndex: 'eveningDistancePrice',
          customRender: (text, record) => {
            return record.eveningDistancePrice+"元"
          }
        },
        {
          title: '夜间开始时间',
          align: 'center',
          dataIndex: 'eveningStartTime'
        },
        {
          title: '夜间结束时间',
          align: 'center',
          dataIndex: 'eveningEndTime'
        },

        // {
        //   title: '虚拟里程',
        //   align: 'center',
        //   dataIndex: 'inventedDistance'
        // },

        // {
        //   title: '状态',
        //   align: 'center',
        //   dataIndex: 'status',
        //   customRender: function(t, r, index) {
        //     return r.status == 1 ? '启用' : '不启用'
        //   }
        // },
        {
          title: '城市服务商所属城市',
          align: 'center',
          dataIndex: 'cityName'
        },
        {
          title: '城市服务商编码',
          align: 'center',
          dataIndex: 'agencyCode'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: '/xhdjCarPrice/list',
        delete: '/xhdjCarPrice/delete',
        deleteBatch: '/xhdjCarPrice/deleteBatch',
        exportXlsUrl: 'xhdjCarPrice/exportXls',
        importExcelUrl: 'xhdjCarPrice/importExcel'
      }
    }
  },
  computed: {
    importExcelUrl: function() {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },
  methods: {
    selectClick(value) {
      this.queryParam.agencyCode = value
      this.searchQuery()
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
